package com.itheima.mapper;

import com.itheima.domain.Huangzhe;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ProductMapper {

    //查询所有患者
    @Results({
            @Result(
                    property = "huangzhe",
                    column = "kid",
                    javaType = Huangzhe.class,
                    one = @One(select = "com.itheima.mapper.ProductMapper.findByid")
            )
    })
    @Select("SELECT * FROM huangzhe")
    List<Huangzhe> findAll();

    //根据患者kid查询,对应的科室
    @Select("SELECT * FROM keshi WHERE id=#{kid}")
    Huangzhe findByid(Integer kid);

    //根据患者名称查询(模糊查询)
    @Results({
            @Result(
                    property = "huangzhe",
                    column = "kid",
                    javaType = Huangzhe.class,
                    one = @One(select = "com.itheima.mapper.ProductMapper.findByid")
            )
    })
    @Select("SELECT * FROM huangzhe where name like CONCAT('%',#{s},'%')")
    List<Huangzhe> findByTiaojian(String s);
}
